package
{
	import com.greensock.plugins.TweenPlugin;
	import com.greensock.plugins.VolumePlugin;
	import flash.display.Sprite;
	import flash.events.Event;
	import org.ichow.debug.Debug;
	import org.ichow.scenegame.SceneGameFacade;
	import org.ichow.version.VersionInfo;
	
	/**
	 * ...
	 * @author M.ichow
	 */
	//[Frame( factoryClass="Preloader" )]
	[SWF( width="680",height="510" )]
	
	public class Main extends Sprite
	{
		
		private var _config : Object = {};
		private var _facade : SceneGameFacade;
		
		public function Main() : void
		{
			if ( stage )
				init();
			else
				addEventListener( Event.ADDED_TO_STAGE , init );
		}
		
		private function init( e : Event = null ) : void
		{
			removeEventListener( Event.ADDED_TO_STAGE , init );
			VersionInfo.init( this );
			
			stage.scaleMode = "noScale";
			stage.align = "TL";
			
			TweenPlugin.activate([ VolumePlugin ] );
			
			if ( stage.loaderInfo.parameters )
				_config = stage.loaderInfo.parameters;
			var path : String = stage.loaderInfo.url;
			if ( path.indexOf( "/" ) != -1 )
			{
				path = path.substr( 0 , path.lastIndexOf( '/' ) + 1 );
			}
			else
			{
				path = path.substr( 0 , path.lastIndexOf( "\\" ) + 1 );
			}
			_config[ "flashPath" ] = path;
			_config[ "width" ] = stage.stageWidth;
			_config[ "height" ] = stage.stageHeight;
			
			//start mvc
			_facade = new SceneGameFacade();
			_facade.startup( this );
		
			Debug.monitor( stage , 1000 );
		}
		
		/**
		 * 获取配置属性
		 * @param	key
		 * @return
		 */
		public function getValueForKey( key : String ) : Object
		{
			return _config[ key ] != null ? _config[ key ] : "";
		}
	}

}